﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;


namespace RMA.Pantallas
{
    public partial class frmVisorReporteGeneral : Form
    {
        public DataTable dtReporteGeneral = null;
        public string Accion = "";

        public frmVisorReporteGeneral(DataTable _dtReporte, string _accion)
        {
            dtReporteGeneral = _dtReporte;
            Accion = _accion;
            InitializeComponent();
        }

        private void frmVisorReporteGeneral_Load(object sender, EventArgs e)
        {
            ugRepGeneral.DataSource = dtReporteGeneral;
            lblAccion.Text = "Status: " + Accion.ToUpper();
        }
        public void ExportarExcel()
        {

            #region input Descripcion
            string Descripcion = null;
            input dialog = new input("Nombre del reporte", "Nombre :", "");
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Descripcion = dialog.ResultText;
                }
                catch { }

            }
            else { }
            #endregion            

            string dr = dialogdireccion() + "//"+ Descripcion+"_RMA"+ (DateTime.Now.Date.ToShortDateString()).Replace("/", "") + ".xls";
            try
            {
                ugExcel.Export(ugRepGeneral, dr);
                Process.Start(dr);

            }
            catch (Exception) { }
        }
        public string dialogdireccion()
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();
            string direccion = "";
            if (folder.ShowDialog() == DialogResult.Cancel)
                return direccion;
            direccion = folder.SelectedPath.ToString();
            return direccion;
        }

        private void btnExportar_Click(object sender, EventArgs e)
        {
            ExportarExcel();
        }

        private void btnImprimir_Click(object sender, EventArgs e)
        {
            frmReporteOrdenServicio frmOrden = new frmReporteOrdenServicio();
            frmOrden.ShowDialog();
            this.Close();
        }

       
    }
}
